package com.tgy.dockerspringboot.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/***
 * @ClassName: TestController
 * @Description:
 * @Auther: 送你一块二向箔
 * @Date: 17:12 2022/4/7
 * @version : V1.0
 */
@RestController
@Slf4j
public class TestController {


    @Resource
    StringRedisTemplate redis;

    @Value("${msg}")
    public String test;
    @RequestMapping("/test")
    public String test(){
        redis.opsForValue().increment("test");
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("现在时间是：yyyy-MM-dd HH:mm:ss");
        String test = redis.opsForValue().get("test");
        String format = now.format(formatter);
        log.info("==============TestController  {} 第{}访问================",format,test);
        return format+"第"+test+"次访问";
    }
}
